<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>flexecm启动设置</title>
<link rel="StyleSheet" href="../css/common.css"  type="text/css">

<script type="text/javascript" language="javascript" src="../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" language="javascript" src="../js/util.js"></script>


<script type="text/javascript">

$(document).ready(function() {
	initUi();
	step1();
	
});

function step1() {
	
	clear();
	$.getJSON("/service/admin/config", null, function (data) {
		if (data.defaultstore!=null) {
			location.href = "home.html";
		} else {
			$("#step1").show();
		}
	});
	
}
function step2() {
	if ($("#new-password").val()=="") {
		showAlert("密码不能为空")
		return;
	}
	
	if ($("#new-password").val()!=$("#re-password").val()) {
		showAlert("2次密码输入不一致")
		return;
	}
	clear();
	$("#step2").show();
}
function step3() {
	clear();
	$("#step3").show();
}

function go() {
	showPenddingMsg("请稍候");
	$.post("/service/init", {
		"pw": $("#new-password").val(),
		"path": $("#default-store").val(),
		"email": $("#email").val(),
		"smtp": $("#smtp").val(),
		"port": $("#smtp-port").val(),
		"emailpass": $("#smtp-password").val()
	}, function (data) {
		var info = JSON.parse(data); 
		if (info.msg == "ok") {
			clear();
			
			$("#finish dd.pass").html(info.pwd);
			$("#finish dd.dir").html(info.defaultstore);
			
			$("#finish dd.email").html(info.adminemail + "  " + (info.adminemailok? "（可用）" :"（不可用）"));
			
			$("#finish").show();
		} else if (info.msg=="initialized"){
			showAlert("已经初始化，点击进入首页", function() {
				location.href = "home.html";
			});
		} else {
			if (info.msg=="666") {
				showAlert("设置的文件存储路径 " + $("#default-store").val() + " 无法使用", step1);	
			} 
		}
		
	});
}

function ok() {
	location.href = "home.html";
}


</script>
<style type="text/css">
#user-table td {
	padding: 10px;
}

</style>
</head>
<body>

<div class="head">
	<div class="logo">
	</div>
	<span style="line-height: 36px; font-size: 16px; color: white;">
		系统处于初始化状态，请完成以下设置
	</span>
</div>


<div class="base">
	
	<div class="center">
		<div id="step1">
			<div class="shadow-box">
				<div class="title">
					第一步： 设置管理密码
				</div>
				<dl class="faceted-filter">
					<dt>密码：</dt>
					<dd>
						<input id="new-password" type="password">
					</dd>
				</dl>
				<dl class="faceted-filter">
					<dt>再输入一次：</dt>
					<dd>
						<input id="re-password" type="password">
					</dd>
				</dl>
				
				<dl class="faceted-filter">
					<dd>
						<a class="contentbtn" onclick="step2();">确定</a>
					</dd>
				</dl>
			</div>
			
		</div>
		<div id="step2">
			<div class="shadow-box">	
				<div class="title">
					第二步： 文件存储位置:	(设置后不可更改)
				</div>
				<dl class="faceted-filter">
					<dt>位置：</dt>
					<dd>
						<input type="text" id="default-store"> 必须为空目录，例如: D:/data或 /user/local/data
					</dd>
				</dl>
				
				<dl class="faceted-filter">
					<dd>
						<a class="contentbtn" onclick="step3();">下一步</a>
					</dd>
				</dl>
			</div>
		</div>
		<div id="step3">
			<div class="shadow-box">
				<div class="title">
					通知邮箱 : （可选， 用于向注册用户发送通知）
				</div>
				
				<dl class="faceted-filter">
					<dt>邮件地址：</dt>
					<dd>
						<input id="email" type="text">
					</dd>
				</dl>
				<dl class="faceted-filter">
					<dt>SMTP：</dt>
					<dd>
						<input id="smtp" type="text">
					</dd>
					<dt>端口：</dt>
					<dd>
						<input id="smtp-port" type="text">
					</dd>
				</dl>
				
				<dl class="faceted-filter">
					<dt>密码：</dt>
					<dd>
						<input id="smtp-password" type="text">
					</dd>
				</dl>
				
				<dl class="faceted-filter">
					<dd>
						<a class="contentbtn" onclick="go();">确定更改</a>
					</dd>
				</dl>
			</div>
		</div>
				
		<div id="finish">
			<div class="shadow-box">
				<div class="title">
					设置成功！ 请牢记以下配置
				</div>
				
				<dl class="faceted-filter">
					<dt>管理员密码：</dt>
					<dd class="pass text">
						
					</dd>
				</dl>
				
				<dl class="faceted-filter">
					<dt>本地目录：</dt>
					<dd class="dir text">
						
					</dd>
				</dl>
				<dl class="faceted-filter">
					<dt>管理邮件：</dt>
					<dd class="email text">
						
					</dd>
				</dl>
				
				<dl class="faceted-filter">
					<dd>
						<a class="contentbtn" onclick="ok();">完成</a>
					</dd>
				</dl>
			</div>
		
		</div>
		<div id="loadingMask" style="/* display: none; */ /* opacity: 0; */"><div></div><span>初始化，请稍候...</span></div>
	</div>
</div>


<div class="dialog" id="pendding-dialog">
	<div class="title">请稍候</div>
	<div class="content">
		
	</div>
</div>


<div class="dialog" id="alert-dialog">
	<div class="title">请注意</div>
	<div class="content" style="padding: 18px;">
		
	</div>
	<div class="buttons">
		<a class="button blue right confirm" >确定</a>
	</div>
</div>

<div class="hide-bg">
</div>

</body>
</html>